//
//  TopCollectionViewCell.m
//  Movie
//
//  Created by tengyang on 15/7/21.
//  Copyright (c) 2015年 tengyang. All rights reserved.
//

#import "TopCollectionViewCell.h"
#import "starView.h"
#import "UIImageView+WebCache.h"

@implementation TopCollectionViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setModal:(TopModal *)modal
{
    _modal=modal;
    [self setNeedsLayout];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    _titleLable.text=_modal.title;
    NSString *temp=[_modal.images objectForKey:@"medium"];
    [_iconImage sd_setImageWithURL:[NSURL URLWithString:temp]];
    
    _bgView.backgroundColor=[UIColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:0.7];
    
    
    UIImage *grayImage=[UIImage imageNamed:@"gray"];
    UIImage *yelowImage=[UIImage imageNamed:@"yellow"];
    UIView *grayView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, grayImage.size.width*5, grayImage.size.height)];
    UIView *yellowView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, yelowImage.size.width*_modal.average*0.5, yelowImage.size.height)];
    grayView.backgroundColor=[UIColor colorWithPatternImage:grayImage];
    yellowView.backgroundColor=[UIColor colorWithPatternImage:yelowImage];
    [_starView addSubview:grayView];
    [_starView addSubview:yellowView];
    
    
    _averageLable.text=[NSString stringWithFormat:@"%.1f",_modal.average];
    
}

@end
